package 笔试;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class 简易迷宫 {
    /*
    简易迷宫,1为墙，0为通路，玩家为%，走出迷宫，并且0设为#
     */
    public static void main(String[] args) {
        String[][] a = new String[10][10];
        //迷宫矩阵，到达边缘即为通过→下标为[0][x],[9][x],[x][0],[x][9]的都是结束
        a[0] = new String[]{"1","1","1","1","1","1","0","1","1","1"};
        a[1] = new String[]{"1","0","1","1","1","1","0","1","0","1"};
        a[2] = new String[]{"1","0","0","0","1","0","0","1","0","1"};
        a[3] = new String[]{"1","0","1","0","1","0","1","0","0","1"};
        a[4] = new String[]{"1","0","1","0","0","0","0","0","1","1"};
        a[5] = new String[]{"1","0","1","1","0","1","0","1","1","1"};
        a[6] = new String[]{"1","1","1","1","0","1","0","0","0","1"};
        a[7] = new String[]{"1","1","0","1","0","1","0","1","0","1"};
        a[8] = new String[]{"1","0","%","0","0","1","0","0","0","1"};
        a[9] = new String[]{"1","1","1","1","1","1","1","1","1","1"};
        //已知人物从[8][2]出发，每走一步都查找周围是不是墙，如果有分支路线则生成新的路线
        int x = 8;
        int y = 2;
        //存储走过的路线
        ArrayList list = new ArrayList();
        HashMap map = new HashMap();
        find(a,x,y,0,5,list,map);
    }

    /**
     * @param a 传入的矩阵
     * @param x 初始x下标
     * @param y 初始y下标
     * @param count 记录第几次变道
     * @param move 记录是往哪里移动 0上 1下 2左 3右 5无
     * @param list 存储map
     * @param map  存储路线
     */
    public static void find(String[][] a, int x, int y, int count, int move, ArrayList list,HashMap map){
        //走迷宫,尝试往上走,如果已经走过则跳过
        if (a[x-1][y].equals("0") && move != 1){
            //路是通的，记录路线
            x = x-1;
            map.put(x,y);
        }


    }
}
